﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo02
{
    //1、猫、狗、鸭、猴，（吃、游泳、爬树）

    class Program
    {
        static void Main(string[] args)
        {
            Cat cat = new Cat("cat1");
            Dog dog = new Dog("dog1");
            Duck duck = new Duck("duck1");
            Monkey monkey = new Monkey("monkey1");
            AnimalActoin(cat);
            AnimalActoin(dog);
            AnimalActoin(duck);
            AnimalActoin(monkey);

            AnimalClimb(cat);
            AnimalClimb(monkey);

            AnimalSwim(dog);
            AnimalSwim(duck);
        }
        static void AnimalActoin(Animal a) 
        {
            a.Eat();
        }
        static void AnimalClimb(IClimb c)
        {
            c.Climb();
        }
        static void AnimalSwim(ISwim s)
        {
            s.Swim();
        }
    }

    interface ISwim
    {
        void Swim();
    }
    interface IClimb
    {
        void Climb();
    }
    abstract class Animal
    {
        private string name;

        public string Name { get => name; set => name = value; }

        protected Animal(string name)
        {
            Name = name;
        }
        public Animal()
        {

        }

        public abstract void Eat();
    }

    class Cat : Animal, IClimb
    {
        public Cat(string name) : base(name)
        {
        }

        public void Climb()
        {
            Console.WriteLine($"cat {this.Name} is Climbing");
        }

        public override void Eat()
        {
            Console.WriteLine($"cat {this.Name} is Eating");
        }
    }

    class Monkey : Animal, IClimb
    {
        public Monkey(string name) : base(name)
        {
        }

        public void Climb()
        {
            Console.WriteLine($"monkey {this.Name} is Climbing");
        }

        public override void Eat()
        {
            Console.WriteLine($"monkey {this.Name} is Eating");
        }
    }

    class Dog : Animal, ISwim
    {
        public Dog(string name) : base(name)
        {
        }
        public override void Eat()
        {
            Console.WriteLine($"dog {this.Name} is Eating");
        }

        public void Swim()
        {
            Console.WriteLine($"Dog {this.Name} is swinming");
        }
    }

    class Duck : Animal, ISwim
    {
        public Duck(string name) : base(name)
        {
        }
        public override void Eat()
        {
            Console.WriteLine($"duck {this.Name} is Eating");
        }

        public void Swim()
        {
            Console.WriteLine($"duck {this.Name} is swinming");
        }
    }
}
